<?php
namespace app\index\controller;
use app\index\model\Common;
use \think\View;
class Index extends HomeController
{
	/**
	 * 获取
	 *
	 * @author Cheng
	 *
	 * @DateTime 2016-05-28
	 *
	 * @return   [type]     [description]
	 */
    public function index()
    {
        $view = new View();
        $common = new Common;
        $list = $common->select('article');
        return $view->fetch('index',['list'=>$list]);
    }
    //my博文
    public function profile()
    {
        $user_id = $_GET['u'];
        $common = new Common;
        $list = $common->select('article', $user_id);
        $view = new View();
        return $view->fetch('profile',['list'=>$list]);

    }
    //发微博方法
    public function post()
    {
        if(empty($_SESSION['user_id']) ) {
            return $this->error('go die');
            exit();
        }
        $data = array();
        $data['content'] = $_POST['status'];
        $data['user_id'] = $_SESSION['user_id'];
        $data['flag'] = 1;
        $data['starttime'] = time();
        $common = new Common;
        $bool = $common->inster('article',$data);
        if( $bool ) {
            return $this->success('write ok');
        }else{
            return $this->error('write error');
        }
    }
}
